public class T4E03
{   
	public static void main(String args[])
	{  
		CCustomer c1=new CCustomer();
		CCustomer c2=new CCustomer();
		c1.start();   
		c2.start();
		//CBank.add(100); 
		//CBank.add(100); 
		//CBank.add(100); 
		//CBank.add(100); 
	}
}
class CBank
{     
	private static int sum = 0;
    public static void add(int n)
	{
		//int tmp = sum;
		//tmp = tmp + n;   // 累加汇款总额
		try
		{
			Thread.sleep((int)(100*Math.random()));  // 小睡几秒钟
		}
		catch(InterruptedException e)
		{
			e.printStackTrace();
		} 
		sum = sum + n;
		System.out.println("sum= " + sum); 
	}
}

class CCustomer extends Thread  // CCustomer类，继承自Thread类
{  
	public void run()
	{   
		for(int i=1;i<=3;i++)
        CBank.add(100);   // 将100元分三次汇入
	}
}